# coding=utf-8
from django.contrib import admin
from django.conf import settings
from apps.research.models import ResearchGroup, ResearchArticle, ResearchPublication

class GroupAdmin(admin.ModelAdmin):
    list_display = ('group_rank', 'group_name_en', 'group_name_zh', 'group_tag')
    list_filter = ('group_rank', )
    list_max_show_all = 100     #   如果放不下，改这个数字
    list_per_page = 10
    search_fields = ['group_name_en']

    class Media:
        js = [settings.MEDIA_URL+'plugins/tiny_mce/tiny_mce_src.js', 
              #settings.MEDIA_URL+'plugins/tiny_mce/tiny_mce_config.js',
              settings.MEDIA_URL+'plugins/filebrowser/js/TinyMCEAdmin.js'
             ]

class ArticleAdmin(admin.ModelAdmin):
    list_display = ('article_group', 'article_title_en', 'article_title_zh', 'article_status')
    list_filter = ('article_group', 'article_datetime', 'article_status')
    list_max_show_all = 1000000     #   如果放不下，改这个数字
    list_per_page = 10
    search_fields = ['article_title_en', 'article_title_zh']

    class Media:
        js = [settings.MEDIA_URL+'plugins/tiny_mce/tiny_mce_src.js', 
              #settings.MEDIA_URL+'plugins/tiny_mce/tiny_mce_config.js',
              settings.MEDIA_URL+'plugins/filebrowser/js/TinyMCEAdmin.js'
             ]

class PublicationAdmin(admin.ModelAdmin):
    list_display = ('publication_rank', 'publication_name_en', 'publication_name_zh')
    list_filter = ('publication_rank', )
    list_max_show_all = 100
    list_per_page = 10
    search_fields = ['publication_name_en', 'publication_name_zh']

    class Media:
        js = [settings.MEDIA_URL+'plugins/tiny_mce/tiny_mce_src.js', 
              #settings.MEDIA_URL+'plugins/tiny_mce/tiny_mce_config.js',
              settings.MEDIA_URL+'plugins/filebrowser/js/TinyMCEAdmin.js'
             ]

admin.site.register(ResearchGroup, GroupAdmin)
admin.site.register(ResearchArticle, ArticleAdmin)
admin.site.register(ResearchPublication, PublicationAdmin)
